/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pckCompSup;

import javax.print.attribute.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;

/**
 *
 * @author Portable-Maison
 */
public class PlainDocumentMaxLength extends PlainDocument {
  private int maxLength;

  public PlainDocumentMaxLength(int maxLength) {
    this.maxLength = maxLength;
  }

  public void insertString (int offset, String str, AttributeSet a)
    throws BadLocationException { if (getLength() + str.length() > maxLength)
    {
    // Toolkit.getDefaultToolkit().beep();
    }
    else
    {
    super.insertString(offset,str, (javax.swing.text.AttributeSet) a);
    }
  }
}